//
//  XNBillListRequest.m
//  XINNingOA
//
//  Created by samuel on 2021/8/13.
//

#import "XNBillListRequest.h"
#import "XNBillItemModel.h"

@implementation XNBillListRequest

- (NSString *)requestUrl
{
    return @"/api/Signed/GetBillListByAccount";
}

- (YTKRequestMethod)requestMethod{
    return YTKRequestMethodGET;
}

- (id)requestArgument
{
    return @{
        @"account":[[NSUserDefaults standardUserDefaults] objectForKey:@"account"],
    };
}



-(NSArray<XNBillItemModel *> *)billList
{
    NSDictionary *response = [self responseJSONObject];
    if (self.success) {
        NSMutableArray *bills = [NSMutableArray array];
        NSArray *array = response[@"result"][@"data"];
        [array enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
            XNBillItemModel *itemModel = [XNBillItemModel modelWithDictionary:obj];
            [bills addObject:itemModel];
        }];
        return [NSArray arrayWithArray:bills];
        
    }else{
        return nil;
    }
}


@end
